package com.example.springblog.config;

import com.example.springblog.model.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
@ResponseBody
@Slf4j
public class ErrorHandler {
    @ExceptionHandler
    public Result handler(Exception e){
        log.error("发送异常，e:",e);
        return  Result.fail(e.getMessage());
    }
}
